package com.oocl.o2o.admin.entity;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.GenericGenerator;

/**
 * 
 * Merchant
 * 
 */
@Entity
@GenericGenerator(strategy = "uuid", name = "merchantuuid")
public class Merchant {
	@Id
	@GeneratedValue(generator = "merchantuuid")
	@Column(columnDefinition = "char(32)")
	private String id;
	private String uname;
	@Lob
	@Basic(fetch = FetchType.LAZY)
	private byte[] idCard;
	@Lob
	@Basic(fetch = FetchType.LAZY)
	private byte[] portrait;
	private String address;
	private Integer status;
	@OneToOne(mappedBy="merchant",targetEntity=FailReason.class,fetch=FetchType.LAZY)
	private FailReason failReason;
	@OneToMany(mappedBy="merchant",targetEntity=Advertisement.class,fetch=FetchType.LAZY)
	private Set<Advertisement> advertisementSet = new HashSet<Advertisement>();
	
	@OneToMany(mappedBy="merchant",targetEntity=ComplaintInfo.class,fetch=FetchType.LAZY)
	private Set<ComplaintInfo> complaintInfoSet = new HashSet<ComplaintInfo>();

	public Merchant() {
		super();
	}

	public Merchant(String uname, byte[] idCard, byte[] portrait,
			String address, Integer status,
			Set<Advertisement> advertisementSet,
			Set<ComplaintInfo> complaintInfoSet) {
		super();
		this.uname = uname;
		this.idCard = idCard;
		this.portrait = portrait;
		this.address = address;
		this.status = status;
		this.advertisementSet = advertisementSet;
		this.complaintInfoSet = complaintInfoSet;
	}

	public Merchant(String id, String uname, byte[] idCard, byte[] portrait,
			String address, Integer status,
			Set<Advertisement> advertisementSet,
			Set<ComplaintInfo> complaintInfoSet) {
		super();
		this.id = id;
		this.uname = uname;
		this.idCard = idCard;
		this.portrait = portrait;
		this.address = address;
		this.status = status;
		this.advertisementSet = advertisementSet;
		this.complaintInfoSet = complaintInfoSet;
	}
	
	
	

	public Merchant(String uname, String address, Integer status) {
		super();
		this.uname = uname;
		this.address = address;
		this.status = status;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUname() {
		return uname;
	}

	public void setUname(String uname) {
		this.uname = uname;
	}

	public byte[] getIdCard() {
		return idCard;
	}

	public void setIdCard(byte[] idCard) {
		this.idCard = idCard;
	}

	public byte[] getPortrait() {
		return portrait;
	}

	public void setPortrait(byte[] portrait) {
		this.portrait = portrait;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public FailReason getFailReason() {
		return failReason;
	}

	public void setFailReason(FailReason failReason) {
		this.failReason = failReason;
	}

	public Set<Advertisement> getAdvertisementSet() {
		return advertisementSet;
	}

	public void setAdvertisementSet(Set<Advertisement> advertisementSet) {
		this.advertisementSet = advertisementSet;
	}

	public Set<ComplaintInfo> getComplaintInfoSet() {
		return complaintInfoSet;
	}

	public void setComplaintInfoSet(Set<ComplaintInfo> complaintInfoSet) {
		this.complaintInfoSet = complaintInfoSet;
	}

	@Override
	public String toString() {
		return "Merchant [id=" + id + ", uname=" + uname + ", address="
				+ address + ", status=" + status + "]";
	}

	public Merchant(String id, String uname, byte[] idCard, byte[] portrait,
			String address, Integer status, FailReason failReason,
			Set<Advertisement> advertisementSet,
			Set<ComplaintInfo> complaintInfoSet) {
		super();
		this.id = id;
		this.uname = uname;
		this.idCard = idCard;
		this.portrait = portrait;
		this.address = address;
		this.status = status;
		this.failReason = failReason;
		this.advertisementSet = advertisementSet;
		this.complaintInfoSet = complaintInfoSet;
	}

	public Merchant(String uname, byte[] idCard, byte[] portrait,
			String address, Integer status, FailReason failReason,
			Set<Advertisement> advertisementSet,
			Set<ComplaintInfo> complaintInfoSet) {
		super();
		this.uname = uname;
		this.idCard = idCard;
		this.portrait = portrait;
		this.address = address;
		this.status = status;
		this.failReason = failReason;
		this.advertisementSet = advertisementSet;
		this.complaintInfoSet = complaintInfoSet;
	}

	public Merchant(String uname, String address, Integer status,
			FailReason failReason) {
		super();
		this.uname = uname;
		this.address = address;
		this.status = status;
		this.failReason = failReason;
	}

	

}
